 import * as Blockly from 'blockly';
import { Order } from 'blockly/javascript';

// 同步块的代码生成器
export const syncLogGenerators = {
  'sync_log': function (block: Blockly.Block, generator: any) {
    const text = generator.valueToCode(block, 'TEXT', Order.NONE) || "''";
    const syncLog = generator.provideFunction_(
      'syncLog',
      `function ${generator.FUNCTION_NAME_PLACEHOLDER_}(text) {
  // Add text to the output area.
  const outputDiv = document.getElementById('output');
  const textEl = document.createElement('p');
  textEl.innerText = text;
  outputDiv.appendChild(textEl);
}`,
    );
    // Generate the function call for this block.
    const code = `${syncLog}(${text});\n`;
    return code;
  }
}; 